{php include wl_template('common/header');}
<ul class="nav nav-tabs">
	<li class="active"><a href="#">{if Customized::init('distributionText') > 0}共享股东{else}分销{/if}统计</a></li>
</ul>
<div class="app-content">
	<div class="app-filter">
		<div class="filter-list">
			<form action="./index.php" method="get" class="form-horizontal" id="form1">
				<input type="hidden" name="c" value="site" />
	            <input type="hidden" name="a" value="entry" />
	            <input type="hidden" name="m" value="{MODULE_NAME}" />
	            <input type="hidden" name="p" value="{$_W['plugin']}" />
				<input type="hidden" name="ac" value="{$_W['controller']}" />
				<input type="hidden" name="do" value="{$_W['method']}" />
				<input type="hidden" name="days" value="{$days}"/>
				<div class="form-group">
					<label class="col-sm-2 control-label">时间</label>
					<div class="col-sm-9 js-daterange" data-form="#form1">
						<div class="btn-group">
							<a href="{php echo wl_filter_url('days:0');}" class="btn {if $days == 0}btn-primary{else}btn-default{/if}">今天</a>
							<a href="{php echo wl_filter_url('days:6');}" class="btn {if $days == 6}btn-primary{else}btn-default{/if}">最近7天</a>
							<a href="{php echo wl_filter_url('days:29');}" class="btn {if $days == 29}btn-primary{else}btn-default{/if}">最近30天</a>
							<a href="javascript:;" class="btn js-btn-custom {if $days == -1}btn-primary{else}btn-default{/if}">自定义</a>
						</div>
						<span class="btn-daterange js-btn-daterange {if $days != -1}hide{/if}">
							{php echo tpl_select_time_info('stat_day', array('start' => $selstarttime, 'end' => $selendtime));}
						</span>
					</div>
				</div>
				<div class="form-group form-inline">
					<label class="col-sm-2 control-label">{if Customized::init('distributionText') > 0}共享股东{else}分销商{/if}</label>
					<div class="col-sm-9">
						<select name="disid" class="form-control select2 js-select2 width-130" id="select-sid">
							<option value="0" {if !$disid}selected{/if}>全部</option>
							{loop $distributor $dis}
								<option value="{$dis['id']}" {if $dis['id'] == $disid}selected{/if}>{$dis['nickname']}</option>
							{/loop}
						</select>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">柱状图</label>
					<div class="col-sm-9">
						<div class="btn-group">
							<a href="{php echo wl_filter_url('orderby: money')}" class="btn {if $orderby == 'money'}btn-primary{else}btn-default{/if}">佣金金额</a>
							<a href="{php echo wl_filter_url('orderby: ordernum')}" class="btn {if $orderby == 'ordernum'}btn-primary{else}btn-default{/if}">订单数量</a>
						</div>
					</div>
				</div>
			</form>
		</div>
	</div>
	
	<div class="panel panel-stat">
		<div class="panel-heading">
			<h3>总览</h3>
		</div>
		<div class="panel-body">
			<div class="col-md-3">
				<div class="title">
					佣金总额(元)
				</div>
				<div class="num-wrapper">
					<a class="num" href="javascript:;">
						<span id="html-all-fee">￥--</span>
					</a>
				</div>
			</div>
			<div class="col-md-3">
				<div class="title">
					订单总数
				</div>
				<div class="num-wrapper">
					<a class="num" href="javascript:;">
						<span id="html-total-all-order">--</span>
					</a>
				</div>
			</div>
			<div class="col-md-3">
				<div class="title">
					订单总额(元)
				</div>
				<div class="num-wrapper">
					<a class="num" href="javascript:;">
						<span id="html-total-all-money">--</span>
					</a>
				</div>
			</div>
			<div class="col-md-3">
				<div class="title">
					{if Customized::init('distributionText') > 0}共享股东{else}分销商{/if}总人数
				</div>
				<div class="num-wrapper">
					<a class="num" href="javascript:;">
						<span id="html-total-all-num">{$distributornum}</span>
					</a>
				</div>
			</div>
		</div>
		<div class="panel-body">
			<div class="col-md-2">
				<div class="title">
					抢购佣金
				</div>
				<div class="num-wrapper">
					<a class="num" href="javascript:;">
						<span id="html-total-rush-fee">￥--</span>
					</a>
					<span class="info" id="html-total-rush-order">--</span>
				</div>
			</div>
			{if p('wlfightgroup')}
			<div class="col-md-2">
				<div class="title">
					拼团佣金
				</div>
				<div class="num-wrapper">
					<a class="num" href="javascript:;">
						<span id="html-total-fight-fee">￥--</span>
					</a>
					<span class="info" id="html-total-fight-order">--</span>
				</div>
			</div>
			{/if}
			{if p('wlcoupon')}
			<div class="col-md-2">
				<div class="title">
					卡券佣金
				</div>
				<div class="num-wrapper">
					<a class="num" href="javascript:;">
						<span id="html-total-coupon-fee">￥--</span>
					</a>
					<span class="info" id="html-total-coupon-order">--</span>
				</div>
			</div>
			{/if}
			{if p('groupon')}
			<div class="col-md-2">
				<div class="title">
					团购佣金
				</div>
				<div class="num-wrapper">
					<a class="num" href="javascript:;">
						<span id="html-total-groupon-fee">￥--</span>
					</a>
					<span class="info" id="html-total-groupon-order">--</span>
				</div>
			</div>
			{/if}
			{if p('bargain')}
			<div class="col-md-2">
				<div class="title">
					砍价佣金
				</div>
				<div class="num-wrapper">
					<a class="num" href="javascript:;">
						<span id="html-total-bargain-fee">￥--</span>
					</a>
					<span class="info" id="html-total-bargain-order">--</span>
				</div>
			</div>
			{/if}
			{if p('citydelivery')}
			<div class="col-md-2">
				<div class="title">
					同城配送佣金
				</div>
				<div class="num-wrapper">
					<a class="num" href="javascript:;">
						<span id="html-total-citydelivery-fee">￥--</span>
					</a>
					<span class="info" id="html-total-citydelivery-order">--</span>
				</div>
			</div>
			{/if}
			{if p('pocket')}
			<div class="col-md-2">
				<div class="title">
					掌上信息佣金
				</div>
				<div class="num-wrapper">
					<a class="num" href="javascript:;">
						<span id="html-total-pocket-fee">￥--</span>
					</a>
					<span class="info" id="html-total-pocket-order">--</span>
				</div>
			</div>
			{/if}
			<div class="col-md-2">
				<div class="title">
					一卡通佣金
				</div>
				<div class="num-wrapper">
					<a class="num" href="javascript:;">
						<span id="html-total-half-fee">￥--</span>
					</a>
					<span class="info" id="html-total-half-order">--</span>
				</div>
			</div>
			{if p('citycard')}
			<div class="col-md-2">
				<div class="title">
					同城名片佣金
				</div>
				<div class="num-wrapper">
					<a class="num" href="javascript:;">
						<span id="html-total-citycard-fee">￥--</span>
					</a>
					<span class="info" id="html-total-citycard-order">--</span>
				</div>
			</div>
			{/if}
			<div class="col-md-2">
				<div class="title">
					付费入驻佣金
				</div>
				<div class="num-wrapper">
					<a class="num" href="javascript:;">
						<span id="html-total-charge-fee">￥--</span>
					</a>
					<span class="info" id="html-total-charge-order">--</span>
				</div>
			</div>
			<div class="col-md-2">
				<div class="title">
					申请{if Customized::init('distributionText') > 0}共享股东{else}分销商{/if}佣金
				</div>
				<div class="num-wrapper">
					<a class="num" href="javascript:;">
						<span id="html-total-distri-fee">￥--</span>
					</a>
					<span class="info" id="html-total-distri-order">--</span>
				</div>
			</div>
		</div>
	</div>
	
	<div class="panel panel-trend">
		<div class="panel-heading">
			<h3>柱状图</h3>
		</div>
		<div class="panel-body">
			<div id="chart-order-holder" style="width: 100%;height:400px;"></div>
		</div>
	</div>
	
	<div class="app-table-list">
		<div class="table-responsive">
			<table class="table table-bordered table-hover">
				<thead class="navbar-inner">
					<tr>
						<th>日期</th>
						<th>订单数</th>
						<th>总佣金额</th>
						<th>抢购</th>
						{if p('groupon')}<th>团购</th>{/if}
						{if p('wlfightgroup')}<th>拼团</th>{/if}
						{if p('wlcoupon')}<th>卡券</th>{/if}
						{if p('bargain')}<th>砍价</th>{/if}
						{if p('citydelivery')}<th>同城配送</th>{/if}
						<th>一卡通</th>
						{if p('pocket')}<th>掌上信息</th>{/if}
						{if p('citycard')}<th>同城名片</th>{/if}
						<th>付费入驻</th>
						<th>申请{if Customized::init('distributionText') > 0}共享股东{else}分销商{/if}</th>
					</tr>
				</thead>
				<tbody>
				{loop $list $record}
					<tr>
						<td><strong>{$record['date']}</strong></td>
						<td><strong>{$record['ordernum']}</strong></td>
						<td><strong>￥{$record['dismoney']}</strong></td>
						<td><span class="text-success">￥{$record['rush']}</span></td>
						{if p('groupon')}<td><span class="text-success">￥{$record['groupon']}</span></td>{/if}
						{if p('wlfightgroup')}<td><span class="text-success">￥{$record['fight']}</span></td>{/if}
						{if p('wlcoupon')}<td><span class="text-success">￥{$record['coupon']}</span></td>{/if}
						{if p('bargain')}<td><span class="text-success">￥{$record['bargain']}</span></td>{/if}
						{if p('citydelivery')}<td><span class="text-success">￥{$record['citydelivery']}</span></td>{/if}
						<td><span class="text-info">￥{$record['half']}</span></td>
						{if p('pocket')}<td><span class="text-info">￥{$record['pocket']}</span></td>{/if}
						{if p('citycard')}<td><span class="text-info">￥{$record['citycard']}</span></td>{/if}
						<td><span class="text-info">￥{$record['charge']}</span></td>
						<td><span class="text-info">￥{$record['distri']}</span></td>
					</tr>
				{/loop}
				</tbody>
			</table>
		</div>
	</div>
</div>
<script>
	$(function(){
		myrequire(['g2','data-set'],function(){
			$.post(location.href, function(stat){
				var data = $.parseJSON(stat);
				
				//柱状图
				var chart = new G2.Chart({
				  	container: 'chart-order-holder',
				  	forceFit: true,
				  	height: 500
				});
				chart.source(data.list);
				chart.scale('数据', {});
				chart.interval().position('year*数据');
				chart.render();
				
				$('#html-all-fee').html('￥'+ data.dismoney.toFixed(2));
				$('#html-total-all-money').html(data.allmoney.toFixed(2));
				$('#html-total-all-order').html(data.disnum);
				
				$('#html-total-rush-fee').html('￥'+data.rushmoney.toFixed(2));
				$('#html-total-fight-fee').html('￥'+data.fightmoney.toFixed(2));
				$('#html-total-coupon-fee').html('￥'+data.couponmoney.toFixed(2));
				$('#html-total-groupon-fee').html('￥'+data.grouponmoney.toFixed(2));
				$('#html-total-charge-fee').html('￥'+data.chargemoney.toFixed(2));
				$('#html-total-half-fee').html('￥'+data.halfmoney.toFixed(2));
				$('#html-total-distri-fee').html('￥'+data.distrimoney.toFixed(2));
				$('#html-total-pocket-fee').html('￥'+data.pocketmoney.toFixed(2));
				$('#html-total-bargain-fee').html('￥'+data.bargainmoney.toFixed(2));
				$('#html-total-citydelivery-fee').html('￥'+data.citydeliverymoney.toFixed(2));
				$('#html-total-citycard-fee').html('￥'+data.citycardmoney.toFixed(2));

				$('#html-total-rush-order').html(data.rushnum);
				$('#html-total-fight-order').html(data.fightnum);
				$('#html-total-coupon-order').html(data.couponnum);
				$('#html-total-groupon-order').html(data.grouponnum);
				$('#html-total-charge-order').html(data.chargenum);
				$('#html-total-half-order').html(data.halfnum);
				$('#html-total-distri-order').html(data.distrinum);
				$('#html-total-pocket-order').html(data.pocketnum);
				$('#html-total-bargain-order').html(data.bargainnum);
				$('#html-total-citydelivery-order').html(data.citydeliverynum);
				$('#html-total-citycard-order').html(data.citycardnum);


			});
		});
	});
</script>
{php include wl_template('common/footer');}